package com.manor.common.utils;

import android.app.Activity;
import android.content.Intent;

import com.alibaba.android.arouter.launcher.ARouter;
import com.orhanobut.logger.Logger;
import com.manor.common.CommonAppContext;
import com.manor.common.Constants;
import com.manor.common.activity.AbsActivity;
import com.manor.common.bean.ChatAnchorParam;
import com.manor.common.bean.ChatAudienceParam;
import com.manor.common.bean.ChatInfo;
import com.manor.common.em.AuthType;

/**
 * Created by cxf on 2019/2/25.
 */

public class RouteUtil {
    public static final String PATH_LAUNCHER = "/app/LauncherActivity";
    public static final String PATH_LOGIN_INVALID = "/main/LoginInvalidActivity";
    public static final String PATH_USER_HOME = "/main/UserHomeActivity";//已废弃
    public static final String PATH_MAIN = "/main/MainActivity";
    public static final String MAIN_CHAT_AUDIENCE = "/oneonone/ChatAudienceActivity";
    public static final String MAIN_CHAT_ANCHOR = "/oneonone/ChatAnchorActivity";
    public static final String MAIN_MSG_FOLLOW = "/main/FollowActivity";
    public static final String MAIN_MSG_FANS = "/main/FansActivity";
    public static final String MAIN_FACE_EXP = "/main/FaceExpActivity";


    public static final String PATH_AT_FRIEND = "/main/AtFriendActivity";
    public static final String PATH_VIDEO_PUBLISH = "/video/VideoPublishActivity";
    //个人中心
    public static final String PATH_PERSONAL_CENTER = "/main/UserCenterActivity";

    public static final String PC_ARISTOCRATIC_PRIVILEGE = "/pc/AristocraticPrivilegeActivity";//贵族特权
    public static final String PC_FLASH_MASTER = "/pc/FlashMasterActivity";//淘米达人
    public static final String PC_FLASH_SCHOOL = "/pc/FlashSchoolActivity";//淘米学堂
    public static final String PC_INVITE_FRIENDS = "/pc/InviteFriendsActivity";//邀请好友
    public static final String PC_MYGUARDIAN = "/pc/MyGuardianActivity";//我的守护
    public static final String PC_MYINCOME = "/pc/MyIncomeActivity";//我的收益
    public static final String PC_QUICK_RECHARGE = "/pc/QuickRechargeActivity";//快捷充值
    public static final String PC_PERSONAL_SETTINGS = "/pc/PersonalSettingsActivity";//个人设置
    public static final String PC_RECOMMENDED = "/pc/RecommendedActivity";//要上推荐
    public static final String PC_TASK_CENTER = "/pc/TaskCenterActivity";//任务中心
    public static final String PC_VISITOR_RECORD = "/pc/VisitorRecordActivity";//访客记录

    public static final String PC_WEB = "/pc/PcWebActivity";//web
    public static final String PC_AUTHENTICATION = "/pc/AuthenticationActivity";//真人认证
    public static final String PC_Earnings = "/pc/myEarningsActivity";//我的收益
    public static final String PC_Withdrawal = "/pc/withdrawalRecordActivity";//提现记录
    public static final String PC_WithdrawalAccount = "/pc/withdrawalAccountActivity";//提现账户
    public static final String PC_MyGuard = "/pc/MyGuardActivity";//我的守护
    public static final String PC_Visitor = "/pc/VisitorRecordActivity";//访客记录
    //登录
    public static final String PC_INPUT_SMSCODE = "/login/InputSmsCodeActivity";//输入验证码登录
    public static final String PC_INPUT_GENDER = "/login/LoginGenderAgeActivity";//填写资料

    public static final String USER_REPORT = "/dynamic/DynamicReportActivity";//举报界面


    public static final String PC_ADDACCOUNT = "/login/AddAccountActivity";//添加账户

    public static final String PC_PAIRY_FAIRY = "/park/FairyParkActivity";//淘米乐园

    public static final String ELVES_HOME = "/paradise/ElvesHomeActivity";//淘米乐园

    public static final String ELVES_SET_PWD_PROVIDER = "/paradise/HSetPwdProvider";//修改交易密码


    public static final String RELEASA_NEWS = "/dynamic/DynamicPublishActivity";//淘米乐园

    public static final String PATH_SHORT_VIDEO = "/shortvideo/ShortFragment";
    public static final String PATH_S_VIDEO = "/shortvideo/SVideoFragment";

    public static final String IM_CHAT_PROVIDER = "/im/HChatImUtil";
    public static final String TUI_KIT_CHAT_INFO = "/tuikit/HChatInfoUtil";

    public static final String PATH_LOGIN = "/main/login/LoginActivity";
    public static final String PATH_MODIFY_PASSWORD = "/main/login/ModifyPasswordActivity";


    /**
     * 登录过期
     */
    public static void forwardLoginInvalid(String tip) {
        ARouter.getInstance().build(PATH_LOGIN_INVALID)
                .withString(Constants.TIP, tip)
                .navigation();
    }

    /**
     * 举报 	[举报类型 1用户 2动态 3群聊]
     */
    public static void forwardReport(int type, String uid) {
        ARouter.getInstance()
                .build(RouteUtil.USER_REPORT)
                .withString(Constants.TO_UID, uid)
                .withInt(Constants.H_TYPE, type)
                .navigation();
    }



    /**
     * 认证
     */
    public static void forwardFaceExp(AuthType type) {
        CommonAppContext.sInstance.initBDFace();
        ARouter.getInstance().build(MAIN_FACE_EXP)
                .withSerializable(Constants.H_TYPE, type)
                .navigation();
    }


    /**
     * 我的关注
     */
    public static void forwardFollowAct(String id) {
        if (ClickUtil.canClick())
            ARouter.getInstance().build(MAIN_MSG_FOLLOW)
                    .withString(Constants.TO_UID, id)
                    .navigation();
    }

    /**
     * 我的粉丝
     */
    public static void forwardFansAct(String id) {
        if (ClickUtil.canClick())
            ARouter.getInstance().build(MAIN_MSG_FANS)
                    .withString(Constants.TO_UID, id)
                    .navigation();
    }




    /**
     * 跳转到个人主页
     */
    public static void forwardUserHome(String toUid) {
        ARouter.getInstance().build(PATH_PERSONAL_CENTER)
                .withString(Constants.TO_UID, toUid)
                .navigation();
    }

    /**
     * 打开观众直播间
     */
    public static void forwardAudienceActivity(ChatAudienceParam param) {
        forwardAudienceActivity(param, false);
    }

    /**
     * 打开观众直播间
     */
    public static void forwardAudienceActivity(ChatAudienceParam param, boolean isPair) {
        Logger.i("timeCharge== forwardAudienceActivity=" + isPair);
        ARouter.getInstance().build(MAIN_CHAT_AUDIENCE)
                .withParcelable(Constants.CHAT_PARAM_AUD, param)
                .withBoolean(Constants.IS_FROM_PAIR, isPair)
                .navigation();
    }

    /**
     * 打开主播直播间
     */
    public static void forwardAnchorActivity(ChatAnchorParam param) {
        KLog.e("Route#forwardAnchorActivity---------");
        ARouter.getInstance().build(MAIN_CHAT_ANCHOR)
                .withParcelable(Constants.CHAT_PARAM_ANC, param)
                .navigation();
    }

    public static void forwardMainActivity() {
        ARouter.getInstance().build(PATH_MAIN)
                .navigation();
    }


    public static void forwardMainActivity(ChatAnchorParam param) {
        ARouter.getInstance().build(PATH_MAIN)
                .withInt(Constants.CHAT_PARAM_TYPE, Constants.CHAT_PARAM_TYPE_ANC)
                .withParcelable(Constants.CHAT_PARAM_ANC, param)
                .navigation();
    }

    public static void forwardMainActivity(ChatAudienceParam param) {
        ARouter.getInstance().build(PATH_MAIN)
                .withInt(Constants.CHAT_PARAM_TYPE, Constants.CHAT_PARAM_TYPE_AUD)
                .withParcelable(Constants.CHAT_PARAM_AUD, param)
                .navigation();
    }


    /**
     * 跳转到召唤好友
     */
    public static void forwardAtFriend(AbsActivity activity, int requestCode) {
        ARouter.getInstance().build(PATH_AT_FRIEND).navigation(activity, requestCode);
    }

    /**
     * 发布视频
     *
     * @param videoPath
     */
    public static void forwardVideoPublish(String videoPath) {
        ARouter.getInstance().build(PATH_VIDEO_PUBLISH)
                .withString(Constants.VIDEO_PATH, videoPath)
                .withInt(Constants.VIDEO_SAVE_TYPE, Constants.VIDEO_SAVE_PUB)
                .withInt(Constants.VIDEO_MUSIC_ID, 0)
                .navigation();
    }


    /**
     * 个人中心的一些跳转,h5
     *
     * @param path      activity
     * @param pathTitle 页面内容
     */
    public static void forwardPath(String path, int pathTitle) {
        ARouter.getInstance().build(path)
                .withInt(Constants.WEB_TITLE, pathTitle)
                .navigation();
    }

    /**
     * 访客记录
     * @param total 总访客
     */
    public static void forwardVisitor(String total) {
        ARouter.getInstance().build(RouteUtil.PC_Visitor)
                .withString(Constants.FROM, total)
                .navigation();
    }

    /**
     * 我的收益跳轉到二級界面
     *
     * @param path      activity
     * @param pathTitle 页面内容
     */
    public static void forwardEarnings(String path, int pathTitle) {
        ARouter.getInstance().build(path)
                .withInt(Constants.MY_EARNINGS, pathTitle)
                .navigation();
    }

    /**
     * @param path      H5网页后缀
     * @param pathTitle H5网页标题
     */
    public static void forwardPcWeb(String path, int pathTitle) {
        ARouter.getInstance().build(PC_WEB)
                .withString(Constants.WEB_URL, path)
                .withInt(Constants.WEB_TITLE, pathTitle)
                .navigation();
    }


    /**
     *
     * @param pathTitle       H5网页后缀
     * @param pathTitle  H5网页标题
     */
    public static void forwardPcWebs(String url, int pathTitle) {
        ARouter.getInstance().build(PC_WEB)
                .withString(Constants.WEB_URL, url)
                .withInt(Constants.WEB_TITLE, pathTitle)
                .navigation();
    }

    /**
     * 个人中心的一些跳转,原生
     *
     * @param path activity
     */
    public static void forwardPath(String path) {
        ARouter.getInstance().build(path)
                .navigation();
    }

    /**
     * 淘米乐园
     */
    public static void forwardElvesHome() {
        ARouter.getInstance()
                .build(PC_PAIRY_FAIRY)
                .navigation();
    }


    /**
     * 跳转去认证中心
     */
    public static void forwardAuthentication(String authStatus) {
        ARouter.getInstance().build(PC_AUTHENTICATION)
                .withString(Constants.AUTHSTATUS, authStatus)
                .navigation();
    }

    /**
     *
     */
    public static void forwardAddAccount(Activity activity, String authStatus, int requestCode) {
        ARouter.getInstance().build(authStatus)
                .navigation(activity, requestCode);
    }

    /**
     * 添加账户
     */
    public static void forwardAddAccountID(Activity activity, String authStatus, int requestCode, String id) {
        ARouter.getInstance().build(authStatus).withString("id", id)
                .navigation(activity, requestCode);
    }
    /**-------------------------- 新版 -------------------------*/
    public static final String ROUTER_TM_PARADISE_NEW_LYB = "/lyb/LybTmParkActivity";//新版淘米乐园
    /**
     * 淘米乐园
     */
    public static void startActivityFairyParkActivityNewLyb() {
        ARouter.getInstance()
                .build(ROUTER_TM_PARADISE_NEW_LYB)
                .navigation();
    }
}
